package com.ticket.sass.admin.controller;

import com.github.xiaoymin.knife4j.annotations.ApiSupport;
import com.ticket.sass.admin.annotation.Loggable;
import com.ticket.sass.admin.annotation.Module;
import com.ticket.sass.admin.business.DispatchBusiness;
import com.ticket.sass.admin.business.impl.DispatchBusinessImpl;
import com.ticket.sass.admin.dto.input.dispatch.DispatchGuideSaveInput;
import com.ticket.sass.admin.dto.input.dispatch.DispatchGuideTypeInput;
import com.ticket.sass.admin.dto.input.dispatch.DispatchHallConfigInput;
import com.ticket.sass.admin.dto.input.dispatch.HallDispatchListInput;
import com.ticket.sass.admin.dto.output.dispatch.DispatchGuideOutput;
import com.ticket.sass.admin.dto.output.dispatch.HallDispatchListOutput;
import com.ticket.sass.admin.model.PageModel;
import com.ticket.sass.admin.model.ResultModel;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * @author ywb
 * @date 2024-04-08 16:31
 */
@RestController
@RequestMapping("/dispatch")
@Api(tags = "卖品配送接口")
@ApiSupport(order = 8)
public class DispatchController {
    
    final DispatchBusiness dispatchBusiness;
    
    public DispatchController(DispatchBusinessImpl dispatchBusiness) {
        this.dispatchBusiness = dispatchBusiness;
    }
    
    @PutMapping("/hall/config")
    @ApiOperation("设置影厅配送配置")
    @Loggable(module = Module.COMMODITY_DISPATCH, desc = "设置影厅配送配置")
    public ResultModel<String> saveDispatchHallConfig(@RequestBody @Valid DispatchHallConfigInput input) {
        dispatchBusiness.saveDispatchHallConfig(input);
        return ResultModel.success();
    }
    
    @GetMapping("/hall/config")
    @ApiOperation("获取影厅配送配置")
    public ResultModel<PageModel<HallDispatchListOutput>> list(@Valid HallDispatchListInput input) {
        return ResultModel.success(dispatchBusiness.list(input));
    }
    
    @GetMapping("/guide")
    @ApiOperation("获取配送指导配置")
    public ResultModel<DispatchGuideOutput> getDispatchGuideById(
        @Valid DispatchGuideTypeInput input
    ) {
        return ResultModel.success(dispatchBusiness.getDispatchGuide(input));
    }
    
    @PutMapping("/guide")
    @ApiOperation("设置配送指导配置")
    @Loggable(module = Module.COMMODITY_DISPATCH, desc = "设置配送指导配置")
    public ResultModel<String> saveDispatchGuideById(
        @RequestBody @Valid DispatchGuideSaveInput input
    ) {
        dispatchBusiness.saveDispatchGuideById(input);
        return ResultModel.success();
    }
}